package com.imau.session;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/servletA")
public class SessionA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        System.out.println("SessionA");
        //1.获取session
        HttpSession session = request.getSession();
        //2.存储数据
        session.setAttribute("username", "admin");
        //3.销毁session（一般不用）
        session.invalidate();
        System.out.println(session.getId());
    }
}
